<?php

namespace AdminBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use AdminBundle\Utility\Constant;

class AuthGroupType extends AbstractType
{
    const LABEL_ATTR_DEFAULT = ['class' => 'col-sm-3 control-label no-padding-right'];
    const INPUT_ATTR_CLASS = 'col-xs-10 col-sm-5';

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder->add('name', TextType::class, [
            'label' => '组名称',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入组名称',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => true,
        ])->add('note', TextareaType::class, [
            'label' => '注释',
            'label_attr' => Constant::LABEL_ATTR_DEFAULT,
            'attr' => [
                'placeholder' => '请输入注释',
                'class' => Constant::INPUT_ATTR_CLASS],
            'required' => false,
            'empty_data' => '',
        ])->add('isEnabled', CheckboxType::class, array(
                'label' => '启用',
                'label_attr' => Constant::LABEL_ATTR_DEFAULT,
                'attr' => [
                    'class' => 'ace ace-switch ace-switch-5',],
                'required' => false,
            )
        );
        // ->add('ctime')->add('createUser');
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AdminBundle\Entity\AuthGroup'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'adminbundle_authgroup';
    }


}
